package com.wch.SpringBootTestDemo.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.geccocrawler.gecco.GeccoEngine;
import com.geccocrawler.gecco.dynamic.DynamicGecco;

@SuppressWarnings("all")
@Controller
@RequestMapping("/geccoController")
public class TestGeccoController {

	@RequestMapping("/geccoGihub")
	@ResponseBody
	public void testGecco(){
		DynamicGecco.html()
		.gecco("https://github.com/{user}/{project}", "consolePipeline")
		.requestField("request").request().build()
		.stringField("user").requestParameter("user").build()
		.stringField("project").requestParameter().build()
		.stringField("title").csspath(".repository-meta-content").text(false).build()
		.intField("star").csspath(".pagehead-actions li:nth-child(2) .social-count").text(false).build()
		.intField("fork").csspath(".pagehead-actions li:nth-child(3) .social-count").text().build()
		.stringField("contributors").csspath("ul.numbers-summary > li:nth-child(4) > a").href().build()
		.register();

		//开始抓取
		GeccoEngine.create()
		.classpath("com.geccocrawler.gecco.demo")
		.start("https://github.com/xtuhcy/gecco")
		.run();
		
		
	}
}
